import types from './mutation-types'
import { Fetch } from '@/utils/http_common'

const actions = {
	// 任何操作需要用到的获取搜索出来的订单
	getPayments({ commit, dispatch, state }, params = {}) {
		Fetch.get('payments/fetch_payments', { params }).then(res => {
			commit(types.FETCH_PAYMENTS, {
				pay: res
			})
		})
	},
	setFinanceTab({ commit, dispatch, state }, params = {}) {
		commit(types.UPDATE_FINANCE_TAB, {
			financeTab: params.financeTab,
			financeVisi: params.financeVisi
		})
	},
	getFinance({ commit, dispatch, state }, params = {}) {
		Fetch.get('payments', { params }).then(res => {
			commit(types.FETCH_FINANCE, {
				financePage: res.page,
				payments: res.payments
			})
		})
	},
	getInvoice({ commit }, params = {}) {
		Fetch.get('/users/' + params.id + '/fetch_invoices', { params }).then(res => {
			commit(types.GET_INVOICE, {
				financePage: res.page,
				payments: res.invoices
			})
		})
	},
	updateFinanceTab({ commit }, payload) {
		commit(types.UPDATE_FINANCE, payload)
	}
}
export default actions